package com.example.rockapollo.controller;

import com.ctrip.framework.apollo.Config;
import com.ctrip.framework.apollo.ConfigService;
import com.example.rockapollo.config.Constant;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ApolloController {

  @Value("${name:test}")
  private String name;

  @Autowired
  private Constant constant;

  @GetMapping("/getName")
  public String getName(){
    return name;
  }

  @GetMapping("/config")
  public String config(){
    return ConfigService.getAppConfig().getProperty("name",null);
  }

  @GetMapping("/getNoticeName")
  public String getNoticeName(){
    Config notice = ConfigService.getConfig("notice");
    return notice.getProperty("address",null);
  }

  @GetMapping("/constant")
  public Constant getConstant(){
    return constant;
  }

}
